// pages/map/index.js
import {
  shopList
} from '../../static/shop.js'

let QQMapWX = require('../../common/qqmap-wx-jssdk.js');
let qqmapsdk;
Page({
  data: {
    latitude: 0,
    longitude: 0,
    name: 0,
    errMsg: ""
  },
  onLoad: function () {
    qqmapsdk = new QQMapWX({
      key: '6BLBZ-W3QWI-VJMG5-5DS45-567A5-CAB2R'
    });

    this.moveToLocation();
  },
  //移动选点
  moveToLocation: function () {
    wx.chooseLocation({
      success(res) {
        // console.log(res);

        let pages = getCurrentPages();
        let prevPage = pages[pages.length - 2];
        let loc = [res.longitude, res.latitude];

        prevPage.locSelected(res, qqmapsdk);

        wx.navigateBack({
          delta: 1
        })
      },
      fail(err) {
        console.error(err)
        wx.navigateBack({
          delta: 1
        })
      },
      complete() {
        // console.log('complete')
      }
    });
  },

});